home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 126-150 / disk_142 / fracgen / readme < prev    next >
Text File  |  1992-05-06  |  11KB  |  290 lines

  1.  
  2.                      FRACTAL GENERATOR 1.1
  3.                   Copyright (c)1988 Doug Houck
  4.  
  5.  
  6. DISTRIBUTION NOTICE
  7.  
  8.   This Fractal Generator may be freely distributed, so long as this
  9. notice is retained, and no profit is gained from the distribution of
  10. this program.  Please be sure to copy the accompanying subdirectories,
  11. with a "copy all" or by using Workbench.
  12.  
  13. SOURCE CODE
  14.  
  15.   Due to the fact that this program is laced with code that is part
  16. of commercial products (Doug's Math Aquarium, Doug's Color Commander,
  17. both available from Seven Seas Software), the remaining code would be
  18. of little value to you except as examples. So it has been omitted.  
  19.  
  20. BUT WHAT DOES IT DO?
  21.  
  22.   This program grows fractal pictures from seeds you create.  It is 
  23. meant to be a tool for exploring the world of fractals.  It can be
  24. enjoyed on three levels: (1) loading and displaying fractals stored
  25. on disk, (2) modifying existing fractals, and (3) creating your own 
  26. fractals.
  27.  
  28.   The main idea of this program is very simple.  Take a shape composed
  29. of several line segments, and replace each line segment with a small
  30. copy of the entire shape.  Continue doing this until you reach the
  31. resolution limit of your screen.  For example: (Koch Snowflake)
  32.  
  33.               /\
  34. Seed             /  \
  35.         ____/    \____
  36.  
  37.             __/\__
  38. 1st Generation        \    /
  39.         _/\_/    \_/\_
  40.  
  41.  
  42.   What you have is a self-similar fractal.
  43.  
  44.  
  45. GETTING STARTED
  46.  
  47.     There are a number of fractals stored on disk.  To get at them,
  48. just hit Load, and double-click on a filename.  It will plot automatically.
  49. Hit the Menu button to return to the editing screen.
  50.  
  51.     If you wish to edit the shape of a fractal seed, select one of
  52. "Add", "Delete" or "Move" from the Edit menu, and manipulate the shape
  53. with the mouse.  TIP: Keep the fractal seed simple.
  54.  
  55.     To draw a new fractal, select Draw in the Fractal menu.
  56.  
  57.     For more control of the fractal, select Parameters in the Fractal
  58. menu.  See below for more info on Parameters.
  59.  
  60. =================  The Menu options are explained below. ==================
  61.  
  62.    PROJECT
  63.       New        Initialize to simplest fractal - a straight line
  64.       Load       Load fractal seed and colors from disk.  
  65.       Save       Save fractal seed to disk.
  66.       Quit       Quits program.
  67.  
  68.    EDIT
  69.       Add        Adds a point in the nearest line segment.
  70.       Move       Moves the nearest point.
  71.       Delete     Deletes nearest point.
  72.  
  73.    FRACTAL
  74.       Draw       Draws fractal using current parameters and options.
  75.       Parameters Displays current parameters, allows editing.
  76.            See below on Parameters
  77.       Detail     Length of the shortest allowed line segment.
  78.                  Make larger (5?) for faster drawing.
  79.       Depth      Maximum amount of times to replace line segment
  80.                  with copy.  Max 70, based on program stack.
  81.  
  82. MORE COMMANDS
  83.  
  84.     <F1>        Flip screens
  85.     <F2>        Detail
  86.     <F3>        Depth
  87.     Arrow keys    Push fractal seed around screen
  88.     <N>        New Fractal
  89.     <ESC>        Stop plotting
  90.     Menu Button    Flip screens
  91.  
  92.     For ultimate power, you may edit the files in which it saves the 
  93.     seed formulas with any plain ascii editor.  
  94.  
  95. FEEDBACK
  96.  
  97.     The screen title bar gives feedback information as follows:
  98.  
  99.     Degrees1  Length1  Degrees2  Length2  PixelX PixelY
  100.             \/                 \/              \/
  101.        Line to Left       Line to Right   Absolute Pixel Coordinates
  102.  
  103.     Degrees is the change in heading relative to the line to the left.
  104.         (previous line)
  105.     Length is the length of the line in pixels.
  106.     Pixel is the absolute screen location, where y increases from top
  107.         to bottom.
  108.  
  109. PARAMETERS
  110.  
  111.     RECURSION LEVELS means the following parameters are applied on
  112.     a level by level (generation) basis, where the first character
  113.     applies to the first generation, the second character applies
  114.     to the second generation...  The parameters for the level are
  115.     used BEFORE the line segment parameters.
  116.  
  117.     LINE SEGMENTS means the following parameters are applied to
  118.     the individual line segments of the seed shape.  The first
  119.     character applies to the first line segment (starting from the
  120.     left), the second character applies to the second line segment...
  121.  
  122.     REPEATING is applied to each string to make it long enough.
  123.     For example:
  124.         f      = 'ffffffffffffffffffff...'
  125.         fr     = 'frfrfrfrfrfrfrfrfrfr...'
  126.         vii    = 'viiviiviiviiviiviivi...'
  127.     If invalid characters are present, it defaults to the first
  128.     character in the 'f/r' (or whatever) specification.    
  129.  
  130.     DIRECTION can be forward (f) or reverse (r).  Reversing a shape
  131.     means to swap end for end.
  132.     It converts __/\ to /\__
  133.  
  134.     FLIP can be either normal (n) or flipped (f).  Flip means to
  135.     flip the shape along the axis formed by the endpoints of the shape.
  136.     It converts __/\ to __
  137.                           \/
  138.  
  139.     Flip and reverse can be combined, ergo
  140.     both flip and reverse convert __/\ to   __
  141.                                           \/
  142.  
  143.     VISIBLE can be visible (v) or invisible (i).  It is applied to
  144.     each segment of the shape numbered from left to right (as the
  145.     shape was created).
  146.     For instance, 'viv' converts __/\ to __ \
  147.  
  148.     COLOR controls how often the color register is advanced.
  149.     For example, '001' would not increment the color on the first
  150.     2 levels of recursion, but would advance by 1 on the third level.
  151.  
  152.     EXPERIMENT with each of these controls with depth set to 2 or 3,
  153.     a simple shape, varying one parameter at a time.
  154.  
  155. ============================================================================
  156.  
  157.   'Fractal Will Expand' requester - what it means.
  158.  
  159. Imagine a line drawn from one endpoint of your shape to the other.  If any
  160. one of the lines in your shape is bigger than this imaginary line,
  161. the fractal will expand.  The easiest way to fix this is to move your
  162. shape endpoints farther apart, thereby making the component line segments
  163. smaller in comparison.
  164.  
  165.   If you decide to Try It, one of three things may happen.
  166.  
  167.     1.  The line drawing routine tries to draw into a far corner of the
  168.         Amiga's memory.  Corners being what they are, there may be a moron
  169.         program there which is confounded by strange new opcodes.  (Reader
  170.         Problem:  Design a program (a la Core Wars) which can withstand the
  171.         onslaught of a line drawer gone wild.)  The Amiga clips lines that
  172.     wander off the edge of the screen, IF they don't wander too far.
  173.  
  174.     2.  You wisely chose a small Depth, and made sure the line segments
  175.         are only marginally larger than the shape endpoint-to-endpoint
  176.         length.  Some wild lines appear on your screen, but nothing blows
  177.         up.
  178.  
  179.     3.  Time is consumed at the following rate where:
  180.  
  181.         lines_per_second = 650   on the Amiga 1000
  182.         
  183.         Time = ((number_of_line_segments)^Depth)/lines_per_second
  184.  
  185.     For example, the shape /\, which is two sides of an 
  186.     equilateral triangle, if fractalized to a depth of 70,
  187.     would take roughly
  188.  
  189.         (2^70)/650  seconds, or 58 billion years!
  190.  
  191.     Not to knock the Amiga, but that's probably longer than the MTBF.
  192.  
  193. FOR HACKOIDS
  194.  
  195.     You may also enter the seed shapes directly - here's how.
  196.  
  197.     Select Load, and enter the Drawer "Con:0/0/200/50/input".  It will
  198.     give you some "Drawer not Found"s, but hit OK anyhow.  You have
  199.     just opened the console file on the workbench screen.  Pull
  200.     down the FracGen screen part way, and the plotting screen too to
  201.     expose the "input" window on Workbench.
  202.  
  203.     Now type commands in the "input" window just like they would appear
  204.     in a formula file.  The two most useful commands are:
  205.  
  206.         Point x y        ; Line to this point.
  207.  
  208.         Angle degrees length    ; Turn in this direction, and
  209.                     ; draw a line this long.
  210.                     ; This is relative to your current
  211.                     ; heading, a la Turtle Graphics.
  212.  
  213.     I would suggest a sequence like the following for the Koch Snowflake
  214.  
  215.         Point 100 100        ;     ; define starting point
  216.         Angle 0 75        ; __    ; start pointing thisaway-->
  217.         Angle 60 75        ; __/
  218.         Angle -120 75        ; __/\
  219.         Angle 60 75        ; __/\__
  220.  
  221.     Press <CTRL><\> (control and backslash) to terminate input.
  222.     Center the seed with the cursor keys.
  223.  
  224. SAVING FRACTALS
  225.  
  226.     Feel free to add your own beautiful fractals to this collection.
  227. Before you save the fractal, select the Parameters window, and enter your
  228. name and some notes about your particular fractal.
  229.  
  230. IMPLEMENTATION
  231.  
  232.    This was coded in Lattice C, and hacked into Manx C, except for a
  233. custom fixed point multiply in Assembly.  I use the Motorola Fast
  234. Floating Point library for all the shape manipulation, then do all
  235. the fractal drawing with fixed point arithmetic, which cooks on 
  236. multiplication, and really flies on addition and conversion to integers.
  237.  
  238.    Actually, the hardest part was the routine to find the nearest line
  239. segment in Add point.  It requires a rotation of axes before the distance
  240. can be determined.  If you have a large number of points (>10) you will
  241. notice a slight delay as it cranks through all the calculations.
  242.  
  243.   FracGen is sensitive to the default screen size, so it should work OK
  244. on PAL screens, and MoreRows systems.  
  245.  
  246.   The Detail control is optimized for speed, not accuracy.  Rather
  247. than use the righteous distance formula, sqrt( (x2-x1)^2 + (y2-y1)^2 ),
  248. I stop when both the horizontal and vertical distances are shorter than 
  249. the Detail value.  The upshot is that diagonal lines are considered
  250. shorter than they really are.
  251.                     
  252.   There are limitations imposed because of the granular resolution of
  253. computer screens.  For example, a diagonal line may not be exactly 50 
  254. units long, as it snaps to the nearest pixel coordinates.  I could
  255. have implemented virtual coordinates for the scientific community, but
  256. that would have complicated onscreen editing, which is the key to being
  257. user friendly.  (If there is enough interest (read 'money') I may do a
  258. virtual model.)  A possible editing scenario is to select the line
  259. segment/point with the mouse, bringing up a bank of slider gadgets, which
  260. lets the user individually change the length/angle/color/direction/etc.
  261. Got a better idea?  Let me know.
  262.  
  263. REFERENCE
  264.    As usual, I refer you to Benoit B. Mandelbrot's book, The Fractal
  265.    Geometry of Nature, W. H. Freeman and Company, 1977.  Look especially
  266.    around page 43(?), and at the Koch Snowflake, which inspired this
  267.    program.  Also, there are numerous shapes spread around the book.
  268.  
  269.    August 1987 Byte, Creating Fractals (p. 125) by William A. McWorter and
  270.    Jane Morrill Tazelaar.
  271.  
  272. KUDOS
  273.  
  274.   If you derive excessive pleasure from this program, you may send
  275. your appreciation and spare change to:
  276.  
  277.      Doug Houck
  278.      922 West Uncas Road
  279.      Port Townsend, WA  98368
  280.      USA
  281.  
  282.   If this program blows your power supply, crashes your hard disk, or
  283. fails to perform to your expectations, you may send your bills and 
  284. criticisms to:
  285.  
  286.      Bit Bucket
  287.      Track 81
  288.      Daisy Plains, IO 80286
  289.      Nomodemsland
  290.